﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Novel.Sys;

/**
* @Author: AdinZ
* @Q  Q : 1454269
* @Email:adinz@adinz.com
* @Created: 2014/3/31 17:54:17
*
* */
namespace AdinZ.Web.UI
{
    public class Admin_BasePage : System.Web.UI.Page
    {
        public Novel.Sys.BLL.novel_article __bll_art = new Novel.Sys.BLL.novel_article();
        public Novel.Sys.Model.novel_article __model_art = new Novel.Sys.Model.novel_article();
        public Novel.Sys.BLL.novel_chapter __bll_chap = new Novel.Sys.BLL.novel_chapter();
        public Novel.Sys.Model.novel_chapter __model_chap = new Novel.Sys.Model.novel_chapter();
        public Novel.Sys.BLL.novel_group __bll_group = new Novel.Sys.BLL.novel_group();
        public Novel.Sys.Model.novel_group __model_group = new Novel.Sys.Model.novel_group();
        public Novel.Sys.BLL.novel_sort __bll_sort = new Novel.Sys.BLL.novel_sort();
        public Novel.Sys.Model.novel_sort __model_sort = new Novel.Sys.Model.novel_sort();
        public Novel.Sys.Model.novel_user __model_user = new Novel.Sys.Model.novel_user();
        public Novel.Sys.BLL.novel_user __bll_user = new Novel.Sys.BLL.novel_user();

        /// <summary>
        /// 获取分类名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetTypeName(string id)
        {
            __model_sort = __bll_sort.GetModel(int.Parse(id.Trim()));
            return __model_sort.Name;
        }
        /// <summary>
        /// 字节转兆
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        protected string GetSizeMB(string size)
        {
            int ibyte = int.Parse(size);
            float f = (float)ibyte / 1024 / 1024;
            return f.ToString("0.00");
        }
        /// <summary>
        /// 字节转KB
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        protected string GetSizeKB(string size)
        {
            int ibyte = int.Parse(size);
            float f = (float)ibyte / 1024;
            return f.ToString("0.00");
        }
        /// <summary>
        /// 根据ID获取书名
        /// </summary>
        /// <param name="aid"></param>
        /// <returns></returns>
        protected string GetNovelName(string aid)
        {
            return __bll_art.GetNovelName(int.Parse(aid.Trim()));
        }
        /// <summary>
        /// 根据id获取作者
        /// </summary>
        /// <param name="aid"></param>
        /// <returns></returns>
        protected string GetAuthor(string aid)
        {
            return __bll_art.GetAuthor(int.Parse(aid));
        }


        public void CheckUser()
        {
            string JC_UserName = Novel.Utils.CookieUtil.GetAdminName();
            string JC_PassWord = Novel.Utils.CookieUtil.GetAdminPasswd();

            if (!string.IsNullOrEmpty(JC_UserName))
            {
                if (!__bll_user.Exists(JC_UserName.Trim(), JC_PassWord.Trim()))
                    Response.Redirect("Default.aspx");
            }

        }
    }
}
